package com.example.datapedestal.utils.vo;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @author: ThinkPad
 * @since: 2023/10/27 09:32
 * @description:
 */
@AllArgsConstructor
@Data
public class CommonResp<T> {
    //    业务上的成功与失败
    private int code;
    //    返回信息
    private String message;
    //    返回泛型数据 自定义类型
    private T data;
    public CommonResp() {

    }
    public static <T> CommonResp<T> success(T data){
        return new CommonResp<>(200,"操作成功",data);
    }
    public static <T> CommonResp<T> success(String message,T data){

        return new CommonResp<>(200,message,data);
    }
    public static <T> CommonResp failed(ResultCode code){
        return new CommonResp(code.getCode(),code.getMessage(),null);
    }
    public static <T> CommonResp failed(ResultCode code,String message){
        return new CommonResp(code.getCode(),message,null);
    }
}
